package com.zhuiyun.project.api.topicmanage.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.topicmanage.entity.Topic;
import com.zhuiyun.project.api.topicmanage.service.TopicService;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 话题管理控制层 用于话题的查询，修改，添加，删除操作
 * @ClassName TopicController
 * @Description TODO    1112
 * @Author 田
 * @Date 2023/12/11 13:56
 **/
@RestController
@RequestMapping("topicController")
public class TopicController {

    @Resource
    private TopicService topicService;

    /**
    * @Author 田
    * @Description 话题管理查询方法
    * @Date 2023/12/11 14:30
    * @Return com.zhuiyun.project.common.response.CommonResult
    */
    @GetMapping("topicQueryAll")
    @OptLog(modular = "话题管理",type = CommonConstants.SELECT,describe = "查询话题")
    public CommonResult topicQueryAll(Topic topic){
        List<Topic> topics = topicService.topicQueryAll(topic);
        return CommonResult.ok(topics);
    }
    
    /**
    * @Author 田 
    * @Description 话题管理添加方法
    * @Date 2023/12/14 8:52
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param topic
    */
    @PostMapping("topicAdd")
    @OptLog(modular = "话题管理",type = CommonConstants.ADD,describe = "添加话题")
    public CommonResult topicAdd(Topic topic) {
        return topicService.topicAdd(topic);
    }

    /**
    * @Author 田
    * @Description 话题管理删除方法
    * @Date 2023/12/14 10:33
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param topic
    */
    @PostMapping("topicDelete")
    @OptLog(modular = "话题管理",type = CommonConstants.DELETE,describe = "添加话题删除方法")
    public CommonResult topicDelete(Topic topic){
        return topicService.topicDelete(topic);
    }

    /**
    * @Author 田 
    * @Description 话题管理修改方法
    * @Date 2023/12/19 8:57
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param topic
    */
    @PostMapping("topicUpdate")
    @OptLog(modular = "话题管理",type = CommonConstants.UPDATE,describe = "添加话题修改方法")
    public CommonResult topicUpdate(Topic topic){
        return topicService.topicUpdate(topic);
    }

    /**
    * @Author 田 
    * @Description 话题管理修改回显方法
    * @Date 2023/12/19 8:59
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param topic
    */
    @GetMapping("topicUpdateSel")
    @OptLog(modular = "话题管理",type = CommonConstants.SELECT,describe = "话题修改查询方法")
    public CommonResult topicUpdateSel(Topic topic){
        return topicService.topicUpdateSel(topic);
    }
}